/*******************************************************************************
 *                                    ZLG
 *                         ----------------------------
 *                         innovating embedded platform
 *
 * Copyright (c) 2001-2021 Guangzhou ZHIYUAN Electronics Co., Ltd.
 * All rights reserved.
 *
 * Contact information:
 * web site:    https://www.zlg.cn
 *******************************************************************************/
#ifndef __HPM6E00_CLK_H
#define __HPM6E00_CLK_H

#ifdef __cplusplus
extern "C" {
#endif  /* __cplusplus*/
#include "common/hpm_common.h"
#include "common/hpm_errno.h"
#include "core/include/hpm6e00_regs_clk.h"
#include "core/include/hpm6e00_regs_csr.h"
#include "riscv/riscv_core.h"
#include <stdint.h>
#include <string.h>

/* \brief 时钟源组定义 */
#define CLK_SRC_GROUP_COMMON  (0U)
#define CLK_SRC_GROUP_ADC     (1U)
#define CLK_SRC_GROUP_I2S     (2U)
#define CLK_SRC_GROUP_EWDG    (3U)
#define CLK_SRC_GROUP_AHB     (4U)
#define CLK_SRC_GROUP_AXIF    (5U)
#define CLK_SRC_GROUP_AXIS    (6U)
#define CLK_SRC_GROUP_AXIC    (7U)
#define CLK_SRC_GROUP_AXIN    (8U)
#define CLK_SRC_GROUP_PMIC    (9U)
#define CLK_SRC_GROUP_PEWDG   (10U)
#define CLK_SRC_GROUP_CPU0    (11U)
#define CLK_SRC_GROUP_CPU1    (12U)
#define CLK_SRC_GROUP_SRC     (13U)
#define CLK_SRC_GROUP_INVALID (14U)

/* \brief 时钟寄存器组索引宏定义 */
#define SYSCTL_CLOCK_CLK_TOP_CPU0 (0UL)
#define SYSCTL_CLOCK_CLK_TOP_MCT0 (1UL)
#define SYSCTL_CLOCK_CLK_TOP_CPU1 (2UL)
#define SYSCTL_CLOCK_CLK_TOP_MCT1 (3UL)
#define SYSCTL_CLOCK_CLK_TOP_AHB0 (4UL)
#define SYSCTL_CLOCK_CLK_TOP_AXIF (5UL)
#define SYSCTL_CLOCK_CLK_TOP_AXIS (6UL)
#define SYSCTL_CLOCK_CLK_TOP_AXIC (7UL)
#define SYSCTL_CLOCK_CLK_TOP_AXIN (8UL)
#define SYSCTL_CLOCK_CLK_TOP_TMR0 (9UL)
#define SYSCTL_CLOCK_CLK_TOP_TMR1 (10UL)
#define SYSCTL_CLOCK_CLK_TOP_TMR2 (11UL)
#define SYSCTL_CLOCK_CLK_TOP_TMR3 (12UL)
#define SYSCTL_CLOCK_CLK_TOP_TMR4 (13UL)
#define SYSCTL_CLOCK_CLK_TOP_TMR5 (14UL)
#define SYSCTL_CLOCK_CLK_TOP_TMR6 (15UL)
#define SYSCTL_CLOCK_CLK_TOP_TMR7 (16UL)
#define SYSCTL_CLOCK_CLK_TOP_I2C0 (17UL)
#define SYSCTL_CLOCK_CLK_TOP_I2C1 (18UL)
#define SYSCTL_CLOCK_CLK_TOP_I2C2 (19UL)
#define SYSCTL_CLOCK_CLK_TOP_I2C3 (20UL)
#define SYSCTL_CLOCK_CLK_TOP_I2C4 (21UL)
#define SYSCTL_CLOCK_CLK_TOP_I2C5 (22UL)
#define SYSCTL_CLOCK_CLK_TOP_I2C6 (23UL)
#define SYSCTL_CLOCK_CLK_TOP_I2C7 (24UL)
#define SYSCTL_CLOCK_CLK_TOP_SPI0 (25UL)
#define SYSCTL_CLOCK_CLK_TOP_SPI1 (26UL)
#define SYSCTL_CLOCK_CLK_TOP_SPI2 (27UL)
#define SYSCTL_CLOCK_CLK_TOP_SPI3 (28UL)
#define SYSCTL_CLOCK_CLK_TOP_SPI4 (29UL)
#define SYSCTL_CLOCK_CLK_TOP_SPI5 (30UL)
#define SYSCTL_CLOCK_CLK_TOP_SPI6 (31UL)
#define SYSCTL_CLOCK_CLK_TOP_SPI7 (32UL)
#define SYSCTL_CLOCK_CLK_TOP_URT0 (33UL)
#define SYSCTL_CLOCK_CLK_TOP_URT1 (34UL)
#define SYSCTL_CLOCK_CLK_TOP_URT2 (35UL)
#define SYSCTL_CLOCK_CLK_TOP_URT3 (36UL)
#define SYSCTL_CLOCK_CLK_TOP_URT4 (37UL)
#define SYSCTL_CLOCK_CLK_TOP_URT5 (38UL)
#define SYSCTL_CLOCK_CLK_TOP_URT6 (39UL)
#define SYSCTL_CLOCK_CLK_TOP_URT7 (40UL)
#define SYSCTL_CLOCK_CLK_TOP_URT8 (41UL)
#define SYSCTL_CLOCK_CLK_TOP_URT9 (42UL)
#define SYSCTL_CLOCK_CLK_TOP_URT10 (43UL)
#define SYSCTL_CLOCK_CLK_TOP_URT11 (44UL)
#define SYSCTL_CLOCK_CLK_TOP_URT12 (45UL)
#define SYSCTL_CLOCK_CLK_TOP_URT13 (46UL)
#define SYSCTL_CLOCK_CLK_TOP_URT14 (47UL)
#define SYSCTL_CLOCK_CLK_TOP_URT15 (48UL)
#define SYSCTL_CLOCK_CLK_TOP_ANA0 (49UL)
#define SYSCTL_CLOCK_CLK_TOP_ANA1 (50UL)
#define SYSCTL_CLOCK_CLK_TOP_ANA2 (51UL)
#define SYSCTL_CLOCK_CLK_TOP_ANA3 (52UL)
#define SYSCTL_CLOCK_CLK_TOP_AUD0 (53UL)
#define SYSCTL_CLOCK_CLK_TOP_AUD1 (54UL)
#define SYSCTL_CLOCK_CLK_TOP_CAN0 (55UL)
#define SYSCTL_CLOCK_CLK_TOP_CAN1 (56UL)
#define SYSCTL_CLOCK_CLK_TOP_CAN2 (57UL)
#define SYSCTL_CLOCK_CLK_TOP_CAN3 (58UL)
#define SYSCTL_CLOCK_CLK_TOP_CAN4 (59UL)
#define SYSCTL_CLOCK_CLK_TOP_CAN5 (60UL)
#define SYSCTL_CLOCK_CLK_TOP_CAN6 (61UL)
#define SYSCTL_CLOCK_CLK_TOP_CAN7 (62UL)
#define SYSCTL_CLOCK_CLK_TOP_XPI0 (63UL)
#define SYSCTL_CLOCK_CLK_TOP_FEMC (64UL)
#define SYSCTL_CLOCK_CLK_TOP_ETH0 (65UL)
#define SYSCTL_CLOCK_CLK_TOP_PTP0 (66UL)
#define SYSCTL_CLOCK_CLK_TOP_NTM0 (67UL)
#define SYSCTL_CLOCK_CLK_TOP_REF0 (68UL)
#define SYSCTL_CLOCK_CLK_TOP_REF1 (69UL)
#define SYSCTL_CLOCK_CLK_TOP_TSW1 (70UL)
#define SYSCTL_CLOCK_CLK_TOP_TSW2 (71UL)
#define SYSCTL_CLOCK_CLK_TOP_TSW3 (72UL)

/* \brief 寄存器组索引宏定义 */
#define SYSCTL_RESOURCE_CPU0 (0UL)
#define SYSCTL_RESOURCE_CPX0 (1UL)
#define SYSCTL_RESOURCE_CPU1 (8UL)
#define SYSCTL_RESOURCE_CPX1 (9UL)
#define SYSCTL_RESOURCE_POW_CPU0 (21UL)
#define SYSCTL_RESOURCE_POW_CPU1 (22UL)
#define SYSCTL_RESOURCE_POW_OTN (23UL)
#define SYSCTL_RESOURCE_RST_SOC (24UL)
#define SYSCTL_RESOURCE_RST_CPU0 (25UL)
#define SYSCTL_RESOURCE_RST_CPU1 (26UL)
#define SYSCTL_RESOURCE_RST_OTN (27UL)
#define SYSCTL_RESOURCE_CLK_SRC_XTAL (32UL)
#define SYSCTL_RESOURCE_CLK_SRC_PLL0 (33UL)
#define SYSCTL_RESOURCE_CLK_SRC_CLK0_PLL0 (34UL)
#define SYSCTL_RESOURCE_CLK_SRC_CLK1_PLL0 (35UL)
#define SYSCTL_RESOURCE_CLK_SRC_PLL1 (36UL)
#define SYSCTL_RESOURCE_CLK_SRC_CLK0_PLL1 (37UL)
#define SYSCTL_RESOURCE_CLK_SRC_CLK1_PLL1 (38UL)
#define SYSCTL_RESOURCE_CLK_SRC_CLK2_PLL1 (39UL)
#define SYSCTL_RESOURCE_CLK_SRC_PLL2 (40UL)
#define SYSCTL_RESOURCE_CLK_SRC_CLK0_PLL2 (41UL)
#define SYSCTL_RESOURCE_CLK_SRC_CLK1_PLL2 (42UL)
#define SYSCTL_RESOURCE_CLK_SRC_PLL0_REF (43UL)
#define SYSCTL_RESOURCE_CLK_SRC_PLL1_REF (44UL)
#define SYSCTL_RESOURCE_CLK_SRC_PLL2_REF (45UL)
#define SYSCTL_RESOURCE_CLK_TOP_CPU0 (64UL)
#define SYSCTL_RESOURCE_CLK_TOP_MCT0 (65UL)
#define SYSCTL_RESOURCE_CLK_TOP_CPU1 (66UL)
#define SYSCTL_RESOURCE_CLK_TOP_MCT1 (67UL)
#define SYSCTL_RESOURCE_CLK_TOP_AHB0 (68UL)
#define SYSCTL_RESOURCE_CLK_TOP_AXIF (69UL)
#define SYSCTL_RESOURCE_CLK_TOP_AXIS (70UL)
#define SYSCTL_RESOURCE_CLK_TOP_AXIC (71UL)
#define SYSCTL_RESOURCE_CLK_TOP_AXIN (72UL)
#define SYSCTL_RESOURCE_CLK_TOP_TMR0 (73UL)
#define SYSCTL_RESOURCE_CLK_TOP_TMR1 (74UL)
#define SYSCTL_RESOURCE_CLK_TOP_TMR2 (75UL)
#define SYSCTL_RESOURCE_CLK_TOP_TMR3 (76UL)
#define SYSCTL_RESOURCE_CLK_TOP_TMR4 (77UL)
#define SYSCTL_RESOURCE_CLK_TOP_TMR5 (78UL)
#define SYSCTL_RESOURCE_CLK_TOP_TMR6 (79UL)
#define SYSCTL_RESOURCE_CLK_TOP_TMR7 (80UL)
#define SYSCTL_RESOURCE_CLK_TOP_I2C0 (81UL)
#define SYSCTL_RESOURCE_CLK_TOP_I2C1 (82UL)
#define SYSCTL_RESOURCE_CLK_TOP_I2C2 (83UL)
#define SYSCTL_RESOURCE_CLK_TOP_I2C3 (84UL)
#define SYSCTL_RESOURCE_CLK_TOP_I2C4 (85UL)
#define SYSCTL_RESOURCE_CLK_TOP_I2C5 (86UL)
#define SYSCTL_RESOURCE_CLK_TOP_I2C6 (87UL)
#define SYSCTL_RESOURCE_CLK_TOP_I2C7 (88UL)
#define SYSCTL_RESOURCE_CLK_TOP_SPI0 (89UL)
#define SYSCTL_RESOURCE_CLK_TOP_SPI1 (90UL)
#define SYSCTL_RESOURCE_CLK_TOP_SPI2 (91UL)
#define SYSCTL_RESOURCE_CLK_TOP_SPI3 (92UL)
#define SYSCTL_RESOURCE_CLK_TOP_SPI4 (93UL)
#define SYSCTL_RESOURCE_CLK_TOP_SPI5 (94UL)
#define SYSCTL_RESOURCE_CLK_TOP_SPI6 (95UL)
#define SYSCTL_RESOURCE_CLK_TOP_SPI7 (96UL)
#define SYSCTL_RESOURCE_CLK_TOP_URT0 (97UL)
#define SYSCTL_RESOURCE_CLK_TOP_URT1 (98UL)
#define SYSCTL_RESOURCE_CLK_TOP_URT2 (99UL)
#define SYSCTL_RESOURCE_CLK_TOP_URT3 (100UL)
#define SYSCTL_RESOURCE_CLK_TOP_URT4 (101UL)
#define SYSCTL_RESOURCE_CLK_TOP_URT5 (102UL)
#define SYSCTL_RESOURCE_CLK_TOP_URT6 (103UL)
#define SYSCTL_RESOURCE_CLK_TOP_URT7 (104UL)
#define SYSCTL_RESOURCE_CLK_TOP_URT8 (105UL)
#define SYSCTL_RESOURCE_CLK_TOP_URT9 (106UL)
#define SYSCTL_RESOURCE_CLK_TOP_URT10 (107UL)
#define SYSCTL_RESOURCE_CLK_TOP_URT11 (108UL)
#define SYSCTL_RESOURCE_CLK_TOP_URT12 (109UL)
#define SYSCTL_RESOURCE_CLK_TOP_URT13 (110UL)
#define SYSCTL_RESOURCE_CLK_TOP_URT14 (111UL)
#define SYSCTL_RESOURCE_CLK_TOP_URT15 (112UL)
#define SYSCTL_RESOURCE_CLK_TOP_ANA0 (113UL)
#define SYSCTL_RESOURCE_CLK_TOP_ANA1 (114UL)
#define SYSCTL_RESOURCE_CLK_TOP_ANA2 (115UL)
#define SYSCTL_RESOURCE_CLK_TOP_ANA3 (116UL)
#define SYSCTL_RESOURCE_CLK_TOP_AUD0 (117UL)
#define SYSCTL_RESOURCE_CLK_TOP_AUD1 (118UL)
#define SYSCTL_RESOURCE_CLK_TOP_CAN0 (119UL)
#define SYSCTL_RESOURCE_CLK_TOP_CAN1 (120UL)
#define SYSCTL_RESOURCE_CLK_TOP_CAN2 (121UL)
#define SYSCTL_RESOURCE_CLK_TOP_CAN3 (122UL)
#define SYSCTL_RESOURCE_CLK_TOP_CAN4 (123UL)
#define SYSCTL_RESOURCE_CLK_TOP_CAN5 (124UL)
#define SYSCTL_RESOURCE_CLK_TOP_CAN6 (125UL)
#define SYSCTL_RESOURCE_CLK_TOP_CAN7 (126UL)
#define SYSCTL_RESOURCE_CLK_TOP_XPI0 (127UL)
#define SYSCTL_RESOURCE_CLK_TOP_FEMC (128UL)
#define SYSCTL_RESOURCE_CLK_TOP_ETH0 (129UL)
#define SYSCTL_RESOURCE_CLK_TOP_PTP0 (130UL)
#define SYSCTL_RESOURCE_CLK_TOP_REF0 (131UL)
#define SYSCTL_RESOURCE_CLK_TOP_REF1 (132UL)
#define SYSCTL_RESOURCE_CLK_TOP_NTM0 (133UL)
#define SYSCTL_RESOURCE_CLK_TOP_TSW1 (134UL)
#define SYSCTL_RESOURCE_CLK_TOP_TSW2 (135UL)
#define SYSCTL_RESOURCE_CLK_TOP_TSW3 (136UL)
#define SYSCTL_RESOURCE_CLK_TOP_ADC0 (137UL)
#define SYSCTL_RESOURCE_CLK_TOP_ADC1 (138UL)
#define SYSCTL_RESOURCE_CLK_TOP_ADC2 (139UL)
#define SYSCTL_RESOURCE_CLK_TOP_ADC3 (140UL)
#define SYSCTL_RESOURCE_CLK_TOP_I2S0 (141UL)
#define SYSCTL_RESOURCE_CLK_TOP_I2S1 (142UL)
#define SYSCTL_RESOURCE_AHBP (256UL)
#define SYSCTL_RESOURCE_AXIS (257UL)
#define SYSCTL_RESOURCE_AXIC (258UL)
#define SYSCTL_RESOURCE_AXIN (259UL)
#define SYSCTL_RESOURCE_ROM0 (260UL)
#define SYSCTL_RESOURCE_LMM0 (261UL)
#define SYSCTL_RESOURCE_MCT0 (262UL)
#define SYSCTL_RESOURCE_LMM1 (263UL)
#define SYSCTL_RESOURCE_MCT1 (264UL)
#define SYSCTL_RESOURCE_TMR0 (265UL)
#define SYSCTL_RESOURCE_TMR1 (266UL)
#define SYSCTL_RESOURCE_TMR2 (267UL)
#define SYSCTL_RESOURCE_TMR3 (268UL)
#define SYSCTL_RESOURCE_TMR4 (269UL)
#define SYSCTL_RESOURCE_TMR5 (270UL)
#define SYSCTL_RESOURCE_TMR6 (271UL)
#define SYSCTL_RESOURCE_TMR7 (272UL)
#define SYSCTL_RESOURCE_I2C0 (273UL)
#define SYSCTL_RESOURCE_I2C1 (274UL)
#define SYSCTL_RESOURCE_I2C2 (275UL)
#define SYSCTL_RESOURCE_I2C3 (276UL)
#define SYSCTL_RESOURCE_I2C4 (277UL)
#define SYSCTL_RESOURCE_I2C5 (278UL)
#define SYSCTL_RESOURCE_I2C6 (279UL)
#define SYSCTL_RESOURCE_I2C7 (280UL)
#define SYSCTL_RESOURCE_SPI0 (281UL)
#define SYSCTL_RESOURCE_SPI1 (282UL)
#define SYSCTL_RESOURCE_SPI2 (283UL)
#define SYSCTL_RESOURCE_SPI3 (284UL)
#define SYSCTL_RESOURCE_SPI4 (285UL)
#define SYSCTL_RESOURCE_SPI5 (286UL)
#define SYSCTL_RESOURCE_SPI6 (287UL)
#define SYSCTL_RESOURCE_SPI7 (288UL)
#define SYSCTL_RESOURCE_URT0 (289UL)
#define SYSCTL_RESOURCE_URT1 (290UL)
#define SYSCTL_RESOURCE_URT2 (291UL)
#define SYSCTL_RESOURCE_URT3 (292UL)
#define SYSCTL_RESOURCE_URT4 (293UL)
#define SYSCTL_RESOURCE_URT5 (294UL)
#define SYSCTL_RESOURCE_URT6 (295UL)
#define SYSCTL_RESOURCE_URT7 (296UL)
#define SYSCTL_RESOURCE_URT8 (297UL)
#define SYSCTL_RESOURCE_URT9 (298UL)
#define SYSCTL_RESOURCE_URT10 (299UL)
#define SYSCTL_RESOURCE_URT11 (300UL)
#define SYSCTL_RESOURCE_URT12 (301UL)
#define SYSCTL_RESOURCE_URT13 (302UL)
#define SYSCTL_RESOURCE_URT14 (303UL)
#define SYSCTL_RESOURCE_URT15 (304UL)
#define SYSCTL_RESOURCE_CRC0 (305UL)
#define SYSCTL_RESOURCE_TSNS (306UL)
#define SYSCTL_RESOURCE_WDG0 (307UL)
#define SYSCTL_RESOURCE_WDG1 (308UL)
#define SYSCTL_RESOURCE_WDG2 (309UL)
#define SYSCTL_RESOURCE_WDG3 (310UL)
#define SYSCTL_RESOURCE_MBX0 (311UL)
#define SYSCTL_RESOURCE_MBX1 (312UL)
#define SYSCTL_RESOURCE_GPIO (313UL)
#define SYSCTL_RESOURCE_PPI0 (314UL)
#define SYSCTL_RESOURCE_HDMA (315UL)
#define SYSCTL_RESOURCE_LOBS (316UL)
#define SYSCTL_RESOURCE_ADC0 (317UL)
#define SYSCTL_RESOURCE_ADC1 (318UL)
#define SYSCTL_RESOURCE_ADC2 (319UL)
#define SYSCTL_RESOURCE_ADC3 (320UL)
#define SYSCTL_RESOURCE_CMP0 (321UL)
#define SYSCTL_RESOURCE_CMP1 (322UL)
#define SYSCTL_RESOURCE_CMP2 (323UL)
#define SYSCTL_RESOURCE_CMP3 (324UL)
#define SYSCTL_RESOURCE_I2S0 (325UL)
#define SYSCTL_RESOURCE_I2S1 (326UL)
#define SYSCTL_RESOURCE_PDM0 (327UL)
#define SYSCTL_RESOURCE_CLSD (328UL)
#define SYSCTL_RESOURCE_CAN0 (329UL)
#define SYSCTL_RESOURCE_CAN1 (330UL)
#define SYSCTL_RESOURCE_CAN2 (331UL)
#define SYSCTL_RESOURCE_CAN3 (332UL)
#define SYSCTL_RESOURCE_CAN4 (333UL)
#define SYSCTL_RESOURCE_CAN5 (334UL)
#define SYSCTL_RESOURCE_CAN6 (335UL)
#define SYSCTL_RESOURCE_CAN7 (336UL)
#define SYSCTL_RESOURCE_PTPC (337UL)
#define SYSCTL_RESOURCE_QEI0 (338UL)
#define SYSCTL_RESOURCE_QEI1 (339UL)
#define SYSCTL_RESOURCE_QEI2 (340UL)
#define SYSCTL_RESOURCE_QEI3 (341UL)
#define SYSCTL_RESOURCE_QEO0 (342UL)
#define SYSCTL_RESOURCE_QEO1 (343UL)
#define SYSCTL_RESOURCE_QEO2 (344UL)
#define SYSCTL_RESOURCE_QEO3 (345UL)
#define SYSCTL_RESOURCE_PWM0 (346UL)
#define SYSCTL_RESOURCE_PWM1 (347UL)
#define SYSCTL_RESOURCE_PWM2 (348UL)
#define SYSCTL_RESOURCE_PWM3 (349UL)
#define SYSCTL_RESOURCE_RDC0 (350UL)
#define SYSCTL_RESOURCE_RDC1 (351UL)
#define SYSCTL_RESOURCE_SDM0 (352UL)
#define SYSCTL_RESOURCE_SDM1 (353UL)
#define SYSCTL_RESOURCE_PLB0 (354UL)
#define SYSCTL_RESOURCE_SEI0 (355UL)
#define SYSCTL_RESOURCE_MTG0 (356UL)
#define SYSCTL_RESOURCE_MTG1 (357UL)
#define SYSCTL_RESOURCE_VSC0 (358UL)
#define SYSCTL_RESOURCE_VSC1 (359UL)
#define SYSCTL_RESOURCE_CLC0 (360UL)
#define SYSCTL_RESOURCE_CLC1 (361UL)
#define SYSCTL_RESOURCE_EMDS (362UL)
#define SYSCTL_RESOURCE_RNG0 (363UL)
#define SYSCTL_RESOURCE_SDP0 (364UL)
#define SYSCTL_RESOURCE_PKA0 (365UL)
#define SYSCTL_RESOURCE_KMAN (366UL)
#define SYSCTL_RESOURCE_XPI0 (367UL)
#define SYSCTL_RESOURCE_FEMC (368UL)
#define SYSCTL_RESOURCE_RAM0 (369UL)
#define SYSCTL_RESOURCE_RAM1 (370UL)
#define SYSCTL_RESOURCE_XDMA (371UL)
#define SYSCTL_RESOURCE_FFA0 (372UL)
#define SYSCTL_RESOURCE_ETH0 (373UL)
#define SYSCTL_RESOURCE_USB0 (374UL)
#define SYSCTL_RESOURCE_NTM0 (375UL)
#define SYSCTL_RESOURCE_REF0 (376UL)
#define SYSCTL_RESOURCE_REF1 (377UL)
#define SYSCTL_RESOURCE_TSW0 (378UL)
#define SYSCTL_RESOURCE_ESC0 (379UL)


/* \brief 时钟节点定义 */
typedef enum {
    clock_node_cpu0 = SYSCTL_CLOCK_CLK_TOP_CPU0,
    clock_node_mchtmr0 = SYSCTL_CLOCK_CLK_TOP_MCT0,
    clock_node_cpu1 = SYSCTL_CLOCK_CLK_TOP_CPU1,
    clock_node_mchtmr1 = SYSCTL_CLOCK_CLK_TOP_MCT1,
    clock_node_ahb0 = SYSCTL_CLOCK_CLK_TOP_AHB0,
    clock_node_axif = SYSCTL_CLOCK_CLK_TOP_AXIF,
    clock_node_axis = SYSCTL_CLOCK_CLK_TOP_AXIS,
    clock_node_axic = SYSCTL_CLOCK_CLK_TOP_AXIC,
    clock_node_axin = SYSCTL_CLOCK_CLK_TOP_AXIN,
    clock_node_gptmr0 = SYSCTL_CLOCK_CLK_TOP_TMR0,
    clock_node_gptmr1 = SYSCTL_CLOCK_CLK_TOP_TMR1,
    clock_node_gptmr2 = SYSCTL_CLOCK_CLK_TOP_TMR2,
    clock_node_gptmr3 = SYSCTL_CLOCK_CLK_TOP_TMR3,
    clock_node_gptmr4 = SYSCTL_CLOCK_CLK_TOP_TMR4,
    clock_node_gptmr5 = SYSCTL_CLOCK_CLK_TOP_TMR5,
    clock_node_gptmr6 = SYSCTL_CLOCK_CLK_TOP_TMR6,
    clock_node_gptmr7 = SYSCTL_CLOCK_CLK_TOP_TMR7,
    clock_node_i2c0 = SYSCTL_CLOCK_CLK_TOP_I2C0,
    clock_node_i2c1 = SYSCTL_CLOCK_CLK_TOP_I2C1,
    clock_node_i2c2 = SYSCTL_CLOCK_CLK_TOP_I2C2,
    clock_node_i2c3 = SYSCTL_CLOCK_CLK_TOP_I2C3,
    clock_node_i2c4 = SYSCTL_CLOCK_CLK_TOP_I2C4,
    clock_node_i2c5 = SYSCTL_CLOCK_CLK_TOP_I2C5,
    clock_node_i2c6 = SYSCTL_CLOCK_CLK_TOP_I2C6,
    clock_node_i2c7 = SYSCTL_CLOCK_CLK_TOP_I2C7,
    clock_node_spi0 = SYSCTL_CLOCK_CLK_TOP_SPI0,
    clock_node_spi1 = SYSCTL_CLOCK_CLK_TOP_SPI1,
    clock_node_spi2 = SYSCTL_CLOCK_CLK_TOP_SPI2,
    clock_node_spi3 = SYSCTL_CLOCK_CLK_TOP_SPI3,
    clock_node_spi4 = SYSCTL_CLOCK_CLK_TOP_SPI4,
    clock_node_spi5 = SYSCTL_CLOCK_CLK_TOP_SPI5,
    clock_node_spi6 = SYSCTL_CLOCK_CLK_TOP_SPI6,
    clock_node_spi7 = SYSCTL_CLOCK_CLK_TOP_SPI7,
    clock_node_uart0 = SYSCTL_CLOCK_CLK_TOP_URT0,
    clock_node_uart1 = SYSCTL_CLOCK_CLK_TOP_URT1,
    clock_node_uart2 = SYSCTL_CLOCK_CLK_TOP_URT2,
    clock_node_uart3 = SYSCTL_CLOCK_CLK_TOP_URT3,
    clock_node_uart4 = SYSCTL_CLOCK_CLK_TOP_URT4,
    clock_node_uart5 = SYSCTL_CLOCK_CLK_TOP_URT5,
    clock_node_uart6 = SYSCTL_CLOCK_CLK_TOP_URT6,
    clock_node_uart7 = SYSCTL_CLOCK_CLK_TOP_URT7,
    clock_node_uart8 = SYSCTL_CLOCK_CLK_TOP_URT8,
    clock_node_uart9 = SYSCTL_CLOCK_CLK_TOP_URT9,
    clock_node_uart10 = SYSCTL_CLOCK_CLK_TOP_URT10,
    clock_node_uart11 = SYSCTL_CLOCK_CLK_TOP_URT11,
    clock_node_uart12 = SYSCTL_CLOCK_CLK_TOP_URT12,
    clock_node_uart13 = SYSCTL_CLOCK_CLK_TOP_URT13,
    clock_node_uart14 = SYSCTL_CLOCK_CLK_TOP_URT14,
    clock_node_uart15 = SYSCTL_CLOCK_CLK_TOP_URT15,
    clock_node_ana0 = SYSCTL_CLOCK_CLK_TOP_ANA0,
    clock_node_ana1 = SYSCTL_CLOCK_CLK_TOP_ANA1,
    clock_node_ana2 = SYSCTL_CLOCK_CLK_TOP_ANA2,
    clock_node_ana3 = SYSCTL_CLOCK_CLK_TOP_ANA3,
    clock_node_aud0 = SYSCTL_CLOCK_CLK_TOP_AUD0,
    clock_node_aud1 = SYSCTL_CLOCK_CLK_TOP_AUD1,
    clock_node_can0 = SYSCTL_CLOCK_CLK_TOP_CAN0,
    clock_node_can1 = SYSCTL_CLOCK_CLK_TOP_CAN1,
    clock_node_can2 = SYSCTL_CLOCK_CLK_TOP_CAN2,
    clock_node_can3 = SYSCTL_CLOCK_CLK_TOP_CAN3,
    clock_node_can4 = SYSCTL_CLOCK_CLK_TOP_CAN4,
    clock_node_can5 = SYSCTL_CLOCK_CLK_TOP_CAN5,
    clock_node_can6 = SYSCTL_CLOCK_CLK_TOP_CAN6,
    clock_node_can7 = SYSCTL_CLOCK_CLK_TOP_CAN7,
    clock_node_xpi0 = SYSCTL_CLOCK_CLK_TOP_XPI0,
    clock_node_femc = SYSCTL_CLOCK_CLK_TOP_FEMC,
    clock_node_eth0 = SYSCTL_CLOCK_CLK_TOP_ETH0,
    clock_node_ptp0 = SYSCTL_CLOCK_CLK_TOP_PTP0,
    clock_node_ntmr0 = SYSCTL_CLOCK_CLK_TOP_NTM0,
    clock_node_ref0 = SYSCTL_CLOCK_CLK_TOP_REF0,
    clock_node_ref1 = SYSCTL_CLOCK_CLK_TOP_REF1,
    clock_node_tsn1 = SYSCTL_CLOCK_CLK_TOP_TSW1,
    clock_node_tsn2 = SYSCTL_CLOCK_CLK_TOP_TSW2,
    clock_node_tsn3 = SYSCTL_CLOCK_CLK_TOP_TSW3,

    clock_node_adc_start,
    clock_node_adc0 = clock_node_adc_start,
    clock_node_adc1,
    clock_node_adc2,
    clock_node_adc3,

    clock_node_i2s_start,
    clock_node_i2s0 = clock_node_i2s_start,
    clock_node_i2s1,
    clock_node_end,
} clock_node_t;

/* \brief 通用时钟源定义 */
typedef enum {
    clock_source_osc0_clk0 = 0,
    clock_source_pll0_clk0 = 1,
    clock_source_pll0_clk1 = 2,
    clock_source_pll1_clk0 = 3,
    clock_source_pll1_clk1 = 4,
    clock_source_pll1_clk2 = 5,
    clock_source_pll2_clk0 = 6,
    clock_source_pll2_clk1 = 7,
    clock_source_general_source_end,
} clock_source_t;

/* \brief 系统时钟定义 */
typedef enum {
    sysctl_resource_cpu0 = SYSCTL_RESOURCE_CPU0,
    sysctl_resource_cpx0 = SYSCTL_RESOURCE_CPX0,
    sysctl_resource_cpu1 = SYSCTL_RESOURCE_CPU1,
    sysctl_resource_cpx1 = SYSCTL_RESOURCE_CPX1,
    sysctl_resource_pow_cpu0 = SYSCTL_RESOURCE_POW_CPU0,
    sysctl_resource_pow_cpu1 = SYSCTL_RESOURCE_POW_CPU1,
    sysctl_resource_pow_otn = SYSCTL_RESOURCE_POW_OTN,
    sysctl_resource_rst_soc = SYSCTL_RESOURCE_RST_SOC,
    sysctl_resource_rst_cpu0 = SYSCTL_RESOURCE_RST_CPU0,
    sysctl_resource_rst_cpu1 = SYSCTL_RESOURCE_RST_CPU1,
    sysctl_resource_rst_otn = SYSCTL_RESOURCE_RST_OTN,
    sysctl_resource_xtal = SYSCTL_RESOURCE_CLK_SRC_XTAL,
    sysctl_resource_pll0 = SYSCTL_RESOURCE_CLK_SRC_PLL0,
    sysctl_resource_clk0_pll0 = SYSCTL_RESOURCE_CLK_SRC_CLK0_PLL0,
    sysctl_resource_clk1_pll0 = SYSCTL_RESOURCE_CLK_SRC_CLK1_PLL0,
    sysctl_resource_pll1 = SYSCTL_RESOURCE_CLK_SRC_PLL1,
    sysctl_resource_clk0_pll1 = SYSCTL_RESOURCE_CLK_SRC_CLK0_PLL1,
    sysctl_resource_clk1_pll1 = SYSCTL_RESOURCE_CLK_SRC_CLK1_PLL1,
    sysctl_resource_clk2_pll1 = SYSCTL_RESOURCE_CLK_SRC_CLK2_PLL1,
    sysctl_resource_pll2 = SYSCTL_RESOURCE_CLK_SRC_PLL2,
    sysctl_resource_clk0_pll2 = SYSCTL_RESOURCE_CLK_SRC_CLK0_PLL2,
    sysctl_resource_clk1_pll2 = SYSCTL_RESOURCE_CLK_SRC_CLK1_PLL2,
    sysctl_resource_pll0_ref = SYSCTL_RESOURCE_CLK_SRC_PLL0_REF,
    sysctl_resource_pll1_ref = SYSCTL_RESOURCE_CLK_SRC_PLL1_REF,
    sysctl_resource_pll2_ref = SYSCTL_RESOURCE_CLK_SRC_PLL2_REF,

    sysctl_resource_clk_top_cpu0 = SYSCTL_RESOURCE_CLK_TOP_CPU0,
    sysctl_resource_clk_top_mchtmr0 = SYSCTL_RESOURCE_CLK_TOP_MCT0,
    sysctl_resource_clk_top_cpu1 = SYSCTL_RESOURCE_CLK_TOP_CPU1,
    sysctl_resource_clk_top_mchtmr1 = SYSCTL_RESOURCE_CLK_TOP_MCT1,
    sysctl_resource_clk_top_ahb0 = SYSCTL_RESOURCE_CLK_TOP_AHB0,
    sysctl_resource_clk_top_axif = SYSCTL_RESOURCE_CLK_TOP_AXIF,
    sysctl_resource_clk_top_axis = SYSCTL_RESOURCE_CLK_TOP_AXIS,
    sysctl_resource_clk_top_axic = SYSCTL_RESOURCE_CLK_TOP_AXIC,
    sysctl_resource_clk_top_axin = SYSCTL_RESOURCE_CLK_TOP_AXIN,
    sysctl_resource_clk_top_gptmr0 = SYSCTL_RESOURCE_CLK_TOP_TMR0,
    sysctl_resource_clk_top_gptmr1 = SYSCTL_RESOURCE_CLK_TOP_TMR1,
    sysctl_resource_clk_top_gptmr2 = SYSCTL_RESOURCE_CLK_TOP_TMR2,
    sysctl_resource_clk_top_gptmr3 = SYSCTL_RESOURCE_CLK_TOP_TMR3,
    sysctl_resource_clk_top_gptmr4 = SYSCTL_RESOURCE_CLK_TOP_TMR4,
    sysctl_resource_clk_top_gptmr5 = SYSCTL_RESOURCE_CLK_TOP_TMR5,
    sysctl_resource_clk_top_gptmr6 = SYSCTL_RESOURCE_CLK_TOP_TMR6,
    sysctl_resource_clk_top_gptmr7 = SYSCTL_RESOURCE_CLK_TOP_TMR7,
    sysctl_resource_clk_top_i2c0 = SYSCTL_RESOURCE_CLK_TOP_I2C0,
    sysctl_resource_clk_top_i2c1 = SYSCTL_RESOURCE_CLK_TOP_I2C1,
    sysctl_resource_clk_top_i2c2 = SYSCTL_RESOURCE_CLK_TOP_I2C2,
    sysctl_resource_clk_top_i2c3 = SYSCTL_RESOURCE_CLK_TOP_I2C3,
    sysctl_resource_clk_top_i2c4 = SYSCTL_RESOURCE_CLK_TOP_I2C4,
    sysctl_resource_clk_top_i2c5 = SYSCTL_RESOURCE_CLK_TOP_I2C5,
    sysctl_resource_clk_top_i2c6 = SYSCTL_RESOURCE_CLK_TOP_I2C6,
    sysctl_resource_clk_top_i2c7 = SYSCTL_RESOURCE_CLK_TOP_I2C7,
    sysctl_resource_clk_top_spi0 = SYSCTL_RESOURCE_CLK_TOP_SPI0,
    sysctl_resource_clk_top_spi1 = SYSCTL_RESOURCE_CLK_TOP_SPI1,
    sysctl_resource_clk_top_spi2 = SYSCTL_RESOURCE_CLK_TOP_SPI2,
    sysctl_resource_clk_top_spi3 = SYSCTL_RESOURCE_CLK_TOP_SPI3,
    sysctl_resource_clk_top_spi4 = SYSCTL_RESOURCE_CLK_TOP_SPI4,
    sysctl_resource_clk_top_spi5 = SYSCTL_RESOURCE_CLK_TOP_SPI5,
    sysctl_resource_clk_top_spi6 = SYSCTL_RESOURCE_CLK_TOP_SPI6,
    sysctl_resource_clk_top_spi7 = SYSCTL_RESOURCE_CLK_TOP_SPI7,
    sysctl_resource_clk_top_uart0 = SYSCTL_RESOURCE_CLK_TOP_URT0,
    sysctl_resource_clk_top_uart1 = SYSCTL_RESOURCE_CLK_TOP_URT1,
    sysctl_resource_clk_top_uart2 = SYSCTL_RESOURCE_CLK_TOP_URT2,
    sysctl_resource_clk_top_uart3 = SYSCTL_RESOURCE_CLK_TOP_URT3,
    sysctl_resource_clk_top_uart4 = SYSCTL_RESOURCE_CLK_TOP_URT4,
    sysctl_resource_clk_top_uart5 = SYSCTL_RESOURCE_CLK_TOP_URT5,
    sysctl_resource_clk_top_uart6 = SYSCTL_RESOURCE_CLK_TOP_URT6,
    sysctl_resource_clk_top_uart7 = SYSCTL_RESOURCE_CLK_TOP_URT7,
    sysctl_resource_clk_top_uart8 = SYSCTL_RESOURCE_CLK_TOP_URT8,
    sysctl_resource_clk_top_uart9 = SYSCTL_RESOURCE_CLK_TOP_URT9,
    sysctl_resource_clk_top_uart10 = SYSCTL_RESOURCE_CLK_TOP_URT10,
    sysctl_resource_clk_top_uart11 = SYSCTL_RESOURCE_CLK_TOP_URT11,
    sysctl_resource_clk_top_uart12 = SYSCTL_RESOURCE_CLK_TOP_URT12,
    sysctl_resource_clk_top_uart13 = SYSCTL_RESOURCE_CLK_TOP_URT13,
    sysctl_resource_clk_top_uart14 = SYSCTL_RESOURCE_CLK_TOP_URT14,
    sysctl_resource_clk_top_uart15 = SYSCTL_RESOURCE_CLK_TOP_URT15,
    sysctl_resource_clk_top_ana0 = SYSCTL_RESOURCE_CLK_TOP_ANA0,
    sysctl_resource_clk_top_ana1 = SYSCTL_RESOURCE_CLK_TOP_ANA1,
    sysctl_resource_clk_top_ana2 = SYSCTL_RESOURCE_CLK_TOP_ANA2,
    sysctl_resource_clk_top_ana3 = SYSCTL_RESOURCE_CLK_TOP_ANA3,
    sysctl_resource_clk_top_aud0 = SYSCTL_RESOURCE_CLK_TOP_AUD0,
    sysctl_resource_clk_top_aud1 = SYSCTL_RESOURCE_CLK_TOP_AUD1,
    sysctl_resource_clk_top_can0 = SYSCTL_RESOURCE_CLK_TOP_CAN0,
    sysctl_resource_clk_top_can1 = SYSCTL_RESOURCE_CLK_TOP_CAN1,
    sysctl_resource_clk_top_can2 = SYSCTL_RESOURCE_CLK_TOP_CAN2,
    sysctl_resource_clk_top_can3 = SYSCTL_RESOURCE_CLK_TOP_CAN3,
    sysctl_resource_clk_top_can4 = SYSCTL_RESOURCE_CLK_TOP_CAN4,
    sysctl_resource_clk_top_can5 = SYSCTL_RESOURCE_CLK_TOP_CAN5,
    sysctl_resource_clk_top_can6 = SYSCTL_RESOURCE_CLK_TOP_CAN6,
    sysctl_resource_clk_top_can7 = SYSCTL_RESOURCE_CLK_TOP_CAN7,
    sysctl_resource_clk_top_xpi0 = SYSCTL_RESOURCE_CLK_TOP_XPI0,
    sysctl_resource_clk_top_femc = SYSCTL_RESOURCE_CLK_TOP_FEMC,
    sysctl_resource_clk_top_eth0 = SYSCTL_RESOURCE_CLK_TOP_ETH0,
    sysctl_resource_clk_top_ptp0 = SYSCTL_RESOURCE_CLK_TOP_PTP0,
    sysctl_resource_clk_top_ref0 = SYSCTL_RESOURCE_CLK_TOP_REF0,
    sysctl_resource_clk_top_ref1 = SYSCTL_RESOURCE_CLK_TOP_REF1,
    sysctl_resource_clk_top_ntm0 = SYSCTL_RESOURCE_CLK_TOP_NTM0,
    sysctl_resource_clk_top_tsn1 = SYSCTL_RESOURCE_CLK_TOP_TSW1,
    sysctl_resource_clk_top_tsn2 = SYSCTL_RESOURCE_CLK_TOP_TSW2,
    sysctl_resource_clk_top_tsn3 = SYSCTL_RESOURCE_CLK_TOP_TSW3,
    sysctl_resource_clk_top_adc0 = SYSCTL_RESOURCE_CLK_TOP_ADC0,
    sysctl_resource_clk_top_adc1 = SYSCTL_RESOURCE_CLK_TOP_ADC1,
    sysctl_resource_clk_top_adc2 = SYSCTL_RESOURCE_CLK_TOP_ADC2,
    sysctl_resource_clk_top_adc3 = SYSCTL_RESOURCE_CLK_TOP_ADC3,
    sysctl_resource_clk_top_i2s0 = SYSCTL_RESOURCE_CLK_TOP_I2S0,
    sysctl_resource_clk_top_i2s1 = SYSCTL_RESOURCE_CLK_TOP_I2S1,

    sysctl_resource_linkable_start = 256,
    sysctl_resource_ahbp = SYSCTL_RESOURCE_AHBP,
    sysctl_resource_axis = SYSCTL_RESOURCE_AXIS,
    sysctl_resource_axic = SYSCTL_RESOURCE_AXIC,
    sysctl_resource_axin = SYSCTL_RESOURCE_AXIN,
    sysctl_resource_rom0 = SYSCTL_RESOURCE_ROM0,
    sysctl_resource_lmm0 = SYSCTL_RESOURCE_LMM0,
    sysctl_resource_mchtmr0 = SYSCTL_RESOURCE_MCT0,
    sysctl_resource_lmm1 = SYSCTL_RESOURCE_LMM1,
    sysctl_resource_mchtmr1 = SYSCTL_RESOURCE_MCT1,
    sysctl_resource_gptmr0 = SYSCTL_RESOURCE_TMR0,
    sysctl_resource_gptmr1 = SYSCTL_RESOURCE_TMR1,
    sysctl_resource_gptmr2 = SYSCTL_RESOURCE_TMR2,
    sysctl_resource_gptmr3 = SYSCTL_RESOURCE_TMR3,
    sysctl_resource_gptmr4 = SYSCTL_RESOURCE_TMR4,
    sysctl_resource_gptmr5 = SYSCTL_RESOURCE_TMR5,
    sysctl_resource_gptmr6 = SYSCTL_RESOURCE_TMR6,
    sysctl_resource_gptmr7 = SYSCTL_RESOURCE_TMR7,
    sysctl_resource_i2c0 = SYSCTL_RESOURCE_I2C0,
    sysctl_resource_i2c1 = SYSCTL_RESOURCE_I2C1,
    sysctl_resource_i2c2 = SYSCTL_RESOURCE_I2C2,
    sysctl_resource_i2c3 = SYSCTL_RESOURCE_I2C3,
    sysctl_resource_i2c4 = SYSCTL_RESOURCE_I2C4,
    sysctl_resource_i2c5 = SYSCTL_RESOURCE_I2C5,
    sysctl_resource_i2c6 = SYSCTL_RESOURCE_I2C6,
    sysctl_resource_i2c7 = SYSCTL_RESOURCE_I2C7,
    sysctl_resource_spi0 = SYSCTL_RESOURCE_SPI0,
    sysctl_resource_spi1 = SYSCTL_RESOURCE_SPI1,
    sysctl_resource_spi2 = SYSCTL_RESOURCE_SPI2,
    sysctl_resource_spi3 = SYSCTL_RESOURCE_SPI3,
    sysctl_resource_spi4 = SYSCTL_RESOURCE_SPI4,
    sysctl_resource_spi5 = SYSCTL_RESOURCE_SPI5,
    sysctl_resource_spi6 = SYSCTL_RESOURCE_SPI6,
    sysctl_resource_spi7 = SYSCTL_RESOURCE_SPI7,
    sysctl_resource_uart0 = SYSCTL_RESOURCE_URT0,
    sysctl_resource_uart1 = SYSCTL_RESOURCE_URT1,
    sysctl_resource_uart2 = SYSCTL_RESOURCE_URT2,
    sysctl_resource_uart3 = SYSCTL_RESOURCE_URT3,
    sysctl_resource_uart4 = SYSCTL_RESOURCE_URT4,
    sysctl_resource_uart5 = SYSCTL_RESOURCE_URT5,
    sysctl_resource_uart6 = SYSCTL_RESOURCE_URT6,
    sysctl_resource_uart7 = SYSCTL_RESOURCE_URT7,
    sysctl_resource_uart8 = SYSCTL_RESOURCE_URT8,
    sysctl_resource_uart9 = SYSCTL_RESOURCE_URT9,
    sysctl_resource_uart10 = SYSCTL_RESOURCE_URT10,
    sysctl_resource_uart11 = SYSCTL_RESOURCE_URT11,
    sysctl_resource_uart12 = SYSCTL_RESOURCE_URT12,
    sysctl_resource_uart13 = SYSCTL_RESOURCE_URT13,
    sysctl_resource_uart14 = SYSCTL_RESOURCE_URT14,
    sysctl_resource_uart15 = SYSCTL_RESOURCE_URT15,
    sysctl_resource_crc0 = SYSCTL_RESOURCE_CRC0,
    sysctl_resource_tsns = SYSCTL_RESOURCE_TSNS,
    sysctl_resource_wdg0 = SYSCTL_RESOURCE_WDG0,
    sysctl_resource_wdg1 = SYSCTL_RESOURCE_WDG1,
    sysctl_resource_wdg2 = SYSCTL_RESOURCE_WDG2,
    sysctl_resource_wdg3 = SYSCTL_RESOURCE_WDG3,
    sysctl_resource_mbx0 = SYSCTL_RESOURCE_MBX0,
    sysctl_resource_mbx1 = SYSCTL_RESOURCE_MBX1,
    sysctl_resource_gpio = SYSCTL_RESOURCE_GPIO,
    sysctl_resource_ppi0 = SYSCTL_RESOURCE_PPI0,
    sysctl_resource_hdma = SYSCTL_RESOURCE_HDMA,
    sysctl_resource_lobs = SYSCTL_RESOURCE_LOBS,
    sysctl_resource_adc0 = SYSCTL_RESOURCE_ADC0,
    sysctl_resource_adc1 = SYSCTL_RESOURCE_ADC1,
    sysctl_resource_adc2 = SYSCTL_RESOURCE_ADC2,
    sysctl_resource_adc3 = SYSCTL_RESOURCE_ADC3,
    sysctl_resource_cmp0 = SYSCTL_RESOURCE_CMP0,
    sysctl_resource_cmp1 = SYSCTL_RESOURCE_CMP1,
    sysctl_resource_cmp2 = SYSCTL_RESOURCE_CMP2,
    sysctl_resource_cmp3 = SYSCTL_RESOURCE_CMP3,
    sysctl_resource_i2s0 = SYSCTL_RESOURCE_I2S0,
    sysctl_resource_i2s1 = SYSCTL_RESOURCE_I2S1,
    sysctl_resource_i2spdm0 = SYSCTL_RESOURCE_PDM0,
    sysctl_resource_i2sdao = SYSCTL_RESOURCE_CLSD,
    sysctl_resource_can0 = SYSCTL_RESOURCE_CAN0,
    sysctl_resource_can1 = SYSCTL_RESOURCE_CAN1,
    sysctl_resource_can2 = SYSCTL_RESOURCE_CAN2,
    sysctl_resource_can3 = SYSCTL_RESOURCE_CAN3,
    sysctl_resource_can4 = SYSCTL_RESOURCE_CAN4,
    sysctl_resource_can5 = SYSCTL_RESOURCE_CAN5,
    sysctl_resource_can6 = SYSCTL_RESOURCE_CAN6,
    sysctl_resource_can7 = SYSCTL_RESOURCE_CAN7,
    sysctl_resource_ptpc = SYSCTL_RESOURCE_PTPC,
    sysctl_resource_qei0 = SYSCTL_RESOURCE_QEI0,
    sysctl_resource_qei1 = SYSCTL_RESOURCE_QEI1,
    sysctl_resource_qei2 = SYSCTL_RESOURCE_QEI2,
    sysctl_resource_qei3 = SYSCTL_RESOURCE_QEI3,
    sysctl_resource_qeo0 = SYSCTL_RESOURCE_QEO0,
    sysctl_resource_qeo1 = SYSCTL_RESOURCE_QEO1,
    sysctl_resource_qeo2 = SYSCTL_RESOURCE_QEO2,
    sysctl_resource_qeo3 = SYSCTL_RESOURCE_QEO3,
    sysctl_resource_pwm0 = SYSCTL_RESOURCE_PWM0,
    sysctl_resource_pwm1 = SYSCTL_RESOURCE_PWM1,
    sysctl_resource_pwm2 = SYSCTL_RESOURCE_PWM2,
    sysctl_resource_pwm3 = SYSCTL_RESOURCE_PWM3,
    sysctl_resource_rdc0 = SYSCTL_RESOURCE_RDC0,
    sysctl_resource_rdc1 = SYSCTL_RESOURCE_RDC1,
    sysctl_resource_sdm0 = SYSCTL_RESOURCE_SDM0,
    sysctl_resource_sdm1 = SYSCTL_RESOURCE_SDM1,
    sysctl_resource_plb0 = SYSCTL_RESOURCE_PLB0,
    sysctl_resource_sei0 = SYSCTL_RESOURCE_SEI0,
    sysctl_resource_mtg0 = SYSCTL_RESOURCE_MTG0,
    sysctl_resource_mtg1 = SYSCTL_RESOURCE_MTG1,
    sysctl_resource_vsc0 = SYSCTL_RESOURCE_VSC0,
    sysctl_resource_vsc1 = SYSCTL_RESOURCE_VSC1,
    sysctl_resource_clc0 = SYSCTL_RESOURCE_CLC0,
    sysctl_resource_clc1 = SYSCTL_RESOURCE_CLC1,
    sysctl_resource_emds = SYSCTL_RESOURCE_EMDS,
    sysctl_resource_rng0 = SYSCTL_RESOURCE_RNG0,
    sysctl_resource_sdp0 = SYSCTL_RESOURCE_SDP0,
    sysctl_resource_pka0 = SYSCTL_RESOURCE_PKA0,
    sysctl_resource_kman = SYSCTL_RESOURCE_KMAN,
    sysctl_resource_xpi0 = SYSCTL_RESOURCE_XPI0,
    sysctl_resource_femc = SYSCTL_RESOURCE_FEMC,
    sysctl_resource_ram0 = SYSCTL_RESOURCE_RAM0,
    sysctl_resource_ram1 = SYSCTL_RESOURCE_RAM1,
    sysctl_resource_xdma = SYSCTL_RESOURCE_XDMA,
    sysctl_resource_ffa0 = SYSCTL_RESOURCE_FFA0,
    sysctl_resource_eth0 = SYSCTL_RESOURCE_ETH0,
    sysctl_resource_usb0 = SYSCTL_RESOURCE_USB0,
    sysctl_resource_ntmr0 = SYSCTL_RESOURCE_NTM0,
    sysctl_resource_ref0 = SYSCTL_RESOURCE_REF0,
    sysctl_resource_ref1 = SYSCTL_RESOURCE_REF1,
    sysctl_resource_tsn0 = SYSCTL_RESOURCE_TSW0,
    sysctl_resource_esc0 = SYSCTL_RESOURCE_ESC0,
    sysctl_resource_linkable_end,
    sysctl_resource_end = sysctl_resource_linkable_end,
} sysctl_resource_t;


/* \brief PLLCTL 可选数量 */
#define PLLCTL_SOC_PLL_MAX_COUNT   (3U)
/* \brief PLL 引用的时钟频率 */
#define PLLCTL_SOC_PLL_REFCLK_FREQ (24U * 1000000UL)

typedef enum {
    pllctlv2_pll0,
    pllctlv2_pll1,
    pllctlv2_pll2,
    pllctlv2_pll3,
    pllctlv2_pll4,
    pllctlv2_pll5,
    pllctlv2_pll6,
} pllctlv2_pll_t;

typedef enum {
    pllctlv2_clk0,
    pllctlv2_clk1,
    pllctlv2_clk2,
    pllctlv2_clk3,
} pllctlv2_clk_t;

/**
 * \brief 检查目标时钟是否忙
 *
 * \param[in] resource 要检查的时钟源
 *
 * \retval 忙返回 1，否则返回 0
 */
static inline bool_t sysctl_resource_target_is_busy(sysctl_resource_t resource){
    return HPM_SYS_CTL->RESOURCE[resource] & SYSCTL_RESOURCE_LOC_BUSY_MASK;
}

/**
 * \brief 检查目标时钟是否忙
 *
 * \param[in] resource 要检查的时钟节点
 *
 * \retval 忙返回 1，否则返回 0
 */
static inline bool_t sysctl_clock_target_is_busy(uint32_t clock){
    return HPM_SYS_CTL->CLOCK[clock] & SYSCTL_CLOCK_LOC_BUSY_MASK;
}


/**
 * \brief 核心时钟更新
 */
void clk_core_clk_update(void);
/**
 * \brief 获取时钟源时钟频率
 *
 * \param[in] clk_src 时钟源
 *
 * \retval 成功返回时钟频率
 */
uint32_t clk_source_freq_get(clock_source_t clk_src);
/**
 * \brief 获取时钟频率
 *
 * \param[in] clk_src_type 时钟源类型
 * \param[in] clk_node     时钟节点
 *
 * \retval 成功返回时钟频率
 */
uint32_t clk_freq_get(uint8_t clk_src_type, clock_node_t clk_node);
/**
 * \brief 逻辑组添加时钟源
 *
 * \param[in] clk_resource 时钟源
 * \param[in] group        要添加的组
 */
void clk_group_add(sysctl_resource_t clk_resource, uint32_t group);
/**
 * \brief 连接逻辑组到 CPU
 *
 * \param[in] group   连接组
 * \param[in] cpu_idx CPU 索引
 */
void clk_group_cpu_connect(uint32_t group, uint32_t cpu_idx);
/**
 * \brief 设置时钟源分频
 *
 * \param[in] clk_node     时钟节点
 * \param[in] clk_src_type 时钟源类型
 * \param[in] clk_src      时钟源
 * \param[in] div          时钟分频
 *
 * \retval 成功返回 0
 */
int clk_source_divider_set(clock_node_t   clk_node,
                           uint8_t        clk_src_type,
                           clock_source_t clk_src,
                           uint32_t       div);
/**
 * \brief 延时微秒函数
 *
 * \param[in] us 要延时的微秒
 */
void clk_cpu_delay_us(uint32_t us);
/**
 * \brief 延时毫秒函数
 *
 * \param[in] ms 要延时的毫秒
 */
void clk_cpu_delay_ms(uint32_t ms);
#ifdef __cplusplus
}
#endif  /* __cplusplus  */

#endif



